package com.itbaizhan.clouddemooauth2server;

import com.itbaizhan.clouddemooauth2server.utils.Md5Utils;

import java.util.Base64;

public class testMd5 {
    public static void main(String[] args) {
//        byte[] salt = Md5Utils.generateSale();
//        String salt2 = Base64.getEncoder().encodeToString(salt);
//        System.out.println(salt2);  // 6r2a9SieL2OA+oh/zzAYUg==
//        String encrypt = Md5Utils.encrypt("123456", salt);
//        System.out.println(encrypt); // 5MoBR6TomY6obU7n3o70fA==

         byte[] salt = Base64.getDecoder().decode("6r2a9SieL2OA+oh/zzAYUg==");
         String password = "5MoBR6TomY6obU7n3o70fA==";
         String testPassword = Md5Utils.encrypt("123456", salt);
         if(password.equals(testPassword)){
             System.out.println("密码正确");
         }else{
             System.out.println("密码错误");
         }
    }
}
